@namespace MudBlazor.Docs.Examples
<MudStack Justify="@Justify.Center"
          Class="mud-width-full">
    <MudChipSet T="string"
                AllClosable="@true"
                CheckMark="@true"
                SelectionMode="@SelectionMode.MultiSelection"
                OnClose="@OnChipClosed">
        @for (var i = 0; i < _chips.Count; i++)
        {
            var localIndex = i;
            <MudChip Value="@_chips[localIndex]"
                     Color="@((Color)(localIndex % _numberOfColors))" />
        }
    </MudChipSet>
    <MudButton OnClick="@AddChip"
               Variant="@Variant.Filled">
        Add chip
    </MudButton>
</MudStack>

<MudDivider />

<MudStack>
    <MudChip T="string"
             OnClick="@OpenDialogAsync"
             Text="Click to open a dialog" />
</MudStack>

@code {
    [Inject]
    private IDialogService DialogService { get; set; }

    private readonly List<string> _chips = ["Chip 1", "Chip 2", "Chip 3"];
    private int _chipCounter = 3;
    private int _numberOfColors = Enum.GetValues(typeof(Color)).Length;

    private void AddChip()
        => _chips.Add($"Chip {++_chipCounter}");

    private void OnChipClosed(MudChip<string> chip)
        => _chips.Remove(chip.Value);

    private Task OpenDialogAsync()
        => DialogService.ShowMessageBox("Dialog", "This is a dialog");
}